// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Description: Save real kallsyms data to ko
 * Author: Huawei OS Kernel Lab
 * Create: Tue Apr 17 02:24:01 2023
 */
#include <linux/module.h>
#include "extract_kallsyms.h"

extern unsigned int kallsyms_num_syms __weak;
extern int kallsyms_offsets[] __weak;
extern u8 kallsyms_names[] __weak;
extern char kallsyms_token_table[] __weak;
extern u16 kallsyms_token_index[] __weak;
extern unsigned int kallsyms_markers[] __weak;

static struct extract_kallsyms_struct symbuf = {
	.num_syms = &kallsyms_num_syms,
	.offsets = kallsyms_offsets,
	.names = kallsyms_names,
	.token_table = kallsyms_token_table,
	.token_index = kallsyms_token_index,
	.markers = kallsyms_markers,
};

static int __init ldk_load_kallsyms(void)
{
	int ret;

	ret = extract_kallsyms_init(&symbuf);
	if (ret)
		pr_info("Failed to loaded symbols!\n");

	return ret;
}
module_init(ldk_load_kallsyms);

MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(LIBLINUX_EXTRACT_KALLSYMS);
MODULE_DESCRIPTION("load kallsyms");
